import {
	PickupGridViewActionType,
	IPickupGridViewAbility,
	IPickupGridViewControllerParams,
	IPickupGridViewModel,
	IPickupGridViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
    getViewClassNames,
	handleQuickGroupValueChange,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取选择表格视图输入参数
 *
 * @export
 * @return {*}
 */
export function usePickupGridViewProps() {
	return {
		...useViewProps(),
        singleSelect: {
            type: Boolean,
            default: false
        }
	};
}

/**
 * 获取选择表格视图基础
 *
 * @export
 * @param {IPickupGridViewModel} model 选择表格视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function usePickupGridViewBasic(model: IPickupGridViewModel,props: IParam) {
    const getSearchFormSlotName = (props: IParam) =>{
		const showTabPageExp = App.getProjectSetting().multiTabsSetting.show;
		let searchFormSlotName = 'viewHeaderTop';
		if (!showTabPageExp && props.openType == 'ROUTE') {
			searchFormSlotName = 'viewHeaderBottom';
		}
		return searchFormSlotName;
	}
	const getClassNames = (props:IParam) =>{
        return getViewClassNames(model, props);
	}
	return {
		...useViewBasic(model,props),
        getClassNames,
		getSearchFormSlotName,
		handleQuickGroupValueChange,
	};
}

/**
 * 选择表格视图行为
 *
 * @export
 */
export function usePickupGridViewAction(controller: any) {
	return {
		...useViewAction(controller)
	};
}

/**
 * 获取选择表格视图控制器输入参数
 *
 * @export
 * @param {IPickupGridViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<PickupGridViewActionType, IPickupGridViewAbility>>} evt
 * @return {*}  {IPickupGridViewControllerParams<PickupGridViewActionType, IPickupGridViewAbility>}
 */
export function usePickupGridViewControllerParams(
	model: IPickupGridViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<PickupGridViewActionType, IPickupGridViewAbility>>
): IPickupGridViewControllerParams<PickupGridViewActionType, IPickupGridViewAbility> {
	return {
		...useViewControllerParams<IPickupGridViewStore, IPickupGridViewModel>(
			model,
			props,
			evt
		),
	};
}
